#[doc = "Register `SPIRXFIFOCR` reader"]
pub struct R(crate::R<SPIRXFIFOCR_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<SPIRXFIFOCR_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<SPIRXFIFOCR_SPEC>> for R {
    fn from(reader: crate::R<SPIRXFIFOCR_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `SPIRXFIFOCR` writer"]
pub struct W(crate::W<SPIRXFIFOCR_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<SPIRXFIFOCR_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl core::convert::From<crate::W<SPIRXFIFOCR_SPEC>> for W {
    fn from(writer: crate::W<SPIRXFIFOCR_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Threshold for triggering an RX FIFO interrupt.\n\nValue on reset: 1"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum RXINTSIZE_A {
    #[doc = "0: 65."]
    THRESHOLD_65 = 0,
    #[doc = "1: 62."]
    THRESHOLD_62 = 1,
    #[doc = "2: 48."]
    THRESHOLD_48 = 2,
    #[doc = "3: 32."]
    THRESHOLD_32 = 3,
    #[doc = "4: 16."]
    THRESHOLD_16 = 4,
    #[doc = "5: 8."]
    THRESHOLD_8 = 5,
    #[doc = "6: 4."]
    THRESHOLD_4 = 6,
    #[doc = "7: 1."]
    THRESHOLD_1 = 7,
}
impl From<RXINTSIZE_A> for u8 {
    #[inline(always)]
    fn from(variant: RXINTSIZE_A) -> Self {
        variant as _
    }
}
#[doc = "Field `rxintsize` reader - Threshold for triggering an RX FIFO interrupt."]
pub struct RXINTSIZE_R(crate::FieldReader<u8, RXINTSIZE_A>);
impl RXINTSIZE_R {
    pub(crate) fn new(bits: u8) -> Self {
        RXINTSIZE_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> RXINTSIZE_A {
        match self.bits {
            0 => RXINTSIZE_A::THRESHOLD_65,
            1 => RXINTSIZE_A::THRESHOLD_62,
            2 => RXINTSIZE_A::THRESHOLD_48,
            3 => RXINTSIZE_A::THRESHOLD_32,
            4 => RXINTSIZE_A::THRESHOLD_16,
            5 => RXINTSIZE_A::THRESHOLD_8,
            6 => RXINTSIZE_A::THRESHOLD_4,
            7 => RXINTSIZE_A::THRESHOLD_1,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_65`"]
    #[inline(always)]
    pub fn is_threshold_65(&self) -> bool {
        **self == RXINTSIZE_A::THRESHOLD_65
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_62`"]
    #[inline(always)]
    pub fn is_threshold_62(&self) -> bool {
        **self == RXINTSIZE_A::THRESHOLD_62
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_48`"]
    #[inline(always)]
    pub fn is_threshold_48(&self) -> bool {
        **self == RXINTSIZE_A::THRESHOLD_48
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_32`"]
    #[inline(always)]
    pub fn is_threshold_32(&self) -> bool {
        **self == RXINTSIZE_A::THRESHOLD_32
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_16`"]
    #[inline(always)]
    pub fn is_threshold_16(&self) -> bool {
        **self == RXINTSIZE_A::THRESHOLD_16
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_8`"]
    #[inline(always)]
    pub fn is_threshold_8(&self) -> bool {
        **self == RXINTSIZE_A::THRESHOLD_8
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_4`"]
    #[inline(always)]
    pub fn is_threshold_4(&self) -> bool {
        **self == RXINTSIZE_A::THRESHOLD_4
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_1`"]
    #[inline(always)]
    pub fn is_threshold_1(&self) -> bool {
        **self == RXINTSIZE_A::THRESHOLD_1
    }
}
impl core::ops::Deref for RXINTSIZE_R {
    type Target = crate::FieldReader<u8, RXINTSIZE_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `rxintsize` writer - Threshold for triggering an RX FIFO interrupt."]
pub struct RXINTSIZE_W<'a> {
    w: &'a mut W,
}
impl<'a> RXINTSIZE_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: RXINTSIZE_A) -> &'a mut W {
        self.bits(variant.into())
    }
    #[doc = "65."]
    #[inline(always)]
    pub fn threshold_65(self) -> &'a mut W {
        self.variant(RXINTSIZE_A::THRESHOLD_65)
    }
    #[doc = "62."]
    #[inline(always)]
    pub fn threshold_62(self) -> &'a mut W {
        self.variant(RXINTSIZE_A::THRESHOLD_62)
    }
    #[doc = "48."]
    #[inline(always)]
    pub fn threshold_48(self) -> &'a mut W {
        self.variant(RXINTSIZE_A::THRESHOLD_48)
    }
    #[doc = "32."]
    #[inline(always)]
    pub fn threshold_32(self) -> &'a mut W {
        self.variant(RXINTSIZE_A::THRESHOLD_32)
    }
    #[doc = "16."]
    #[inline(always)]
    pub fn threshold_16(self) -> &'a mut W {
        self.variant(RXINTSIZE_A::THRESHOLD_16)
    }
    #[doc = "8."]
    #[inline(always)]
    pub fn threshold_8(self) -> &'a mut W {
        self.variant(RXINTSIZE_A::THRESHOLD_8)
    }
    #[doc = "4."]
    #[inline(always)]
    pub fn threshold_4(self) -> &'a mut W {
        self.variant(RXINTSIZE_A::THRESHOLD_4)
    }
    #[doc = "1."]
    #[inline(always)]
    pub fn threshold_1(self) -> &'a mut W {
        self.variant(RXINTSIZE_A::THRESHOLD_1)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x07 << 3)) | (((value as u16) & 0x07) << 3);
        self.w
    }
}
#[doc = "Configures the burst request of the RX FIFO.\n\nValue on reset: 1"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum DMARXBRSIZEPCLK_A {
    #[doc = "0: The threshold level is 1."]
    THRESHOLD_1 = 0,
    #[doc = "1: The threshold level is 4."]
    THRESHOLD_4 = 1,
    #[doc = "2: The threshold level is 8."]
    THRESHOLD_8 = 2,
    #[doc = "3: The threshold level is 16."]
    THRESHOLD_16 = 3,
    #[doc = "4: The threshold level is 32."]
    THRESHOLD_32 = 4,
    #[doc = "5: The threshold level is 64."]
    THRESHOLD_64 = 5,
}
impl From<DMARXBRSIZEPCLK_A> for u8 {
    #[inline(always)]
    fn from(variant: DMARXBRSIZEPCLK_A) -> Self {
        variant as _
    }
}
#[doc = "Field `dmarxbrsizepclk` reader - Configures the burst request of the RX FIFO."]
pub struct DMARXBRSIZEPCLK_R(crate::FieldReader<u8, DMARXBRSIZEPCLK_A>);
impl DMARXBRSIZEPCLK_R {
    pub(crate) fn new(bits: u8) -> Self {
        DMARXBRSIZEPCLK_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> crate::Variant<u8, DMARXBRSIZEPCLK_A> {
        use crate::Variant::*;
        match self.bits {
            0 => Val(DMARXBRSIZEPCLK_A::THRESHOLD_1),
            1 => Val(DMARXBRSIZEPCLK_A::THRESHOLD_4),
            2 => Val(DMARXBRSIZEPCLK_A::THRESHOLD_8),
            3 => Val(DMARXBRSIZEPCLK_A::THRESHOLD_16),
            4 => Val(DMARXBRSIZEPCLK_A::THRESHOLD_32),
            5 => Val(DMARXBRSIZEPCLK_A::THRESHOLD_64),
            i => Res(i),
        }
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_1`"]
    #[inline(always)]
    pub fn is_threshold_1(&self) -> bool {
        **self == DMARXBRSIZEPCLK_A::THRESHOLD_1
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_4`"]
    #[inline(always)]
    pub fn is_threshold_4(&self) -> bool {
        **self == DMARXBRSIZEPCLK_A::THRESHOLD_4
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_8`"]
    #[inline(always)]
    pub fn is_threshold_8(&self) -> bool {
        **self == DMARXBRSIZEPCLK_A::THRESHOLD_8
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_16`"]
    #[inline(always)]
    pub fn is_threshold_16(&self) -> bool {
        **self == DMARXBRSIZEPCLK_A::THRESHOLD_16
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_32`"]
    #[inline(always)]
    pub fn is_threshold_32(&self) -> bool {
        **self == DMARXBRSIZEPCLK_A::THRESHOLD_32
    }
    #[doc = "Checks if the value of the field is `THRESHOLD_64`"]
    #[inline(always)]
    pub fn is_threshold_64(&self) -> bool {
        **self == DMARXBRSIZEPCLK_A::THRESHOLD_64
    }
}
impl core::ops::Deref for DMARXBRSIZEPCLK_R {
    type Target = crate::FieldReader<u8, DMARXBRSIZEPCLK_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `dmarxbrsizepclk` writer - Configures the burst request of the RX FIFO."]
pub struct DMARXBRSIZEPCLK_W<'a> {
    w: &'a mut W,
}
impl<'a> DMARXBRSIZEPCLK_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: DMARXBRSIZEPCLK_A) -> &'a mut W {
        unsafe { self.bits(variant.into()) }
    }
    #[doc = "The threshold level is 1."]
    #[inline(always)]
    pub fn threshold_1(self) -> &'a mut W {
        self.variant(DMARXBRSIZEPCLK_A::THRESHOLD_1)
    }
    #[doc = "The threshold level is 4."]
    #[inline(always)]
    pub fn threshold_4(self) -> &'a mut W {
        self.variant(DMARXBRSIZEPCLK_A::THRESHOLD_4)
    }
    #[doc = "The threshold level is 8."]
    #[inline(always)]
    pub fn threshold_8(self) -> &'a mut W {
        self.variant(DMARXBRSIZEPCLK_A::THRESHOLD_8)
    }
    #[doc = "The threshold level is 16."]
    #[inline(always)]
    pub fn threshold_16(self) -> &'a mut W {
        self.variant(DMARXBRSIZEPCLK_A::THRESHOLD_16)
    }
    #[doc = "The threshold level is 32."]
    #[inline(always)]
    pub fn threshold_32(self) -> &'a mut W {
        self.variant(DMARXBRSIZEPCLK_A::THRESHOLD_32)
    }
    #[doc = "The threshold level is 64."]
    #[inline(always)]
    pub fn threshold_64(self) -> &'a mut W {
        self.variant(DMARXBRSIZEPCLK_A::THRESHOLD_64)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x07) | ((value as u16) & 0x07);
        self.w
    }
}
impl R {
    #[doc = "Bits 3:5 - Threshold for triggering an RX FIFO interrupt."]
    #[inline(always)]
    pub fn rxintsize(&self) -> RXINTSIZE_R {
        RXINTSIZE_R::new(((self.bits >> 3) & 0x07) as u8)
    }
    #[doc = "Bits 0:2 - Configures the burst request of the RX FIFO."]
    #[inline(always)]
    pub fn dmarxbrsizepclk(&self) -> DMARXBRSIZEPCLK_R {
        DMARXBRSIZEPCLK_R::new((self.bits & 0x07) as u8)
    }
}
impl W {
    #[doc = "Bits 3:5 - Threshold for triggering an RX FIFO interrupt."]
    #[inline(always)]
    pub fn rxintsize(&mut self) -> RXINTSIZE_W {
        RXINTSIZE_W { w: self }
    }
    #[doc = "Bits 0:2 - Configures the burst request of the RX FIFO."]
    #[inline(always)]
    pub fn dmarxbrsizepclk(&mut self) -> DMARXBRSIZEPCLK_W {
        DMARXBRSIZEPCLK_W { w: self }
    }
    #[doc = "Writes raw bits to the register."]
    pub unsafe fn bits(&mut self, bits: u16) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "SPIRXFIFOCR is the SPI RX FIFO control register.\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [spirxfifocr](index.html) module"]
pub struct SPIRXFIFOCR_SPEC;
impl crate::RegisterSpec for SPIRXFIFOCR_SPEC {
    type Ux = u16;
}
#[doc = "`read()` method returns [spirxfifocr::R](R) reader structure"]
impl crate::Readable for SPIRXFIFOCR_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [spirxfifocr::W](W) writer structure"]
impl crate::Writable for SPIRXFIFOCR_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets SPIRXFIFOCR to value 0x09"]
impl crate::Resettable for SPIRXFIFOCR_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0x09
    }
}
